import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:photo_assistant/view/qrcode_scan/qrcode_scan_controller.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';

class QRCodeScannerPage extends StatelessWidget {
  const QRCodeScannerPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GetBuilder<QRCodeScannerController>(
        builder: (QRCodeScannerController controller) {
          return Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                SizedBox(
                  height: 300,
                  width: 300,
                  child: QRView(
                    key: controller.qrKey,
                    onQRViewCreated: controller.onQRViewCreated,
                  ),
                ),
                const SizedBox(height: 20),
                Obx(() => Text(controller.qrCodeResult.value)),
              ],
            ),
          );
        },
      ),
    );
  }
}
